﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibKetoan;
using doiso;

namespace Ketoan
{
	/// <summary>
	/// Summary description for frmTimct.
	/// </summary>
	public class frmTimct : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.Button butIn;
		private System.Windows.Forms.Button butKetthuc;
		private string s_mmyy,s_ngay,sql,format_sotien,user;
		private int i_userid;
		private long l_id;
		private bool bAdmin,bClear=true;
		private AccessData a;
		private Doisototext doiso=new Doisototext();
		private DataTable dtll=new DataTable();
		private DataTable dtct=new DataTable();
		private DataTable dttk=new DataTable();
		private DataTable dtdt=new DataTable();
		private DataTable dtloai=new DataTable();
		private DataTable dtloai1=new DataTable();
		private System.Windows.Forms.ToolTip toolTip1;
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.ComboBox hoatdong;
		private System.Windows.Forms.ComboBox lctug;
		private MaskedBox.MaskedBox ngaygs;
		private MaskedTextBox.MaskedTextBox ctgs;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.ComboBox chuong;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.ComboBox nghiepvu;
		private System.Windows.Forms.TextBox tknoa;
		private System.Windows.Forms.TextBox ttknoa;
		private System.Windows.Forms.Label label45;
		private System.Windows.Forms.ComboBox tcnkp;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.TextBox ttkcoa;
		private System.Windows.Forms.TextBox tkcoa;
		private System.Windows.Forms.TextBox tendt;
		private System.Windows.Forms.TextBox madt;
		private System.Windows.Forms.Label label27;
		private MaskedTextBox.MaskedTextBox soctg;
		private string s_chuong,s_lk,s_lctug,s_nghiepvu,s_chucnang;
		private LibList.List listdt;
		private LibList.List liststk;
		private System.Windows.Forms.CheckBox chkXml;
		private System.Windows.Forms.ComboBox nhom;
		private System.Windows.Forms.Label label28;
		private System.Windows.Forms.Label label29;
		private System.Windows.Forms.Button butTim;
		private System.Windows.Forms.Label label12;
		private MaskedBox.MaskedBox tu;
		private System.Windows.Forms.ComboBox chucnang;
		private MaskedBox.MaskedBox den;
		private System.Windows.Forms.Label label13;
		private System.Windows.Forms.DataGrid dataGrid2;
		private System.Windows.Forms.ComboBox kmco3;
		private System.Windows.Forms.ComboBox kmco2;
		private System.Windows.Forms.ComboBox kmco4;
		private System.Windows.Forms.Label label36;
		private System.Windows.Forms.Label label39;
		private System.Windows.Forms.Label label40;
		private System.Windows.Forms.ComboBox kmno3;
		private System.Windows.Forms.ComboBox kmno2;
		private System.Windows.Forms.ComboBox kmno4;
		private System.Windows.Forms.Label label32;
		private System.Windows.Forms.Label label31;
		private System.Windows.Forms.Label label30;
		private System.Windows.Forms.ComboBox kmco;
		private System.Windows.Forms.Label label18;
		private System.Windows.Forms.ComboBox kmno;
		private System.Windows.Forms.Label label17;
		private System.Windows.Forms.ComboBox lk;
		private System.Windows.Forms.Label label50;
		private System.Windows.Forms.Label label15;
		private System.Windows.Forms.ComboBox tt;
		private MaskedTextBox.MaskedTextBox st1;
		private MaskedTextBox.MaskedTextBox st2;
		private MaskedTextBox.MaskedTextBox soctg2;
		private System.Windows.Forms.CheckBox chkNoco;
		private System.Windows.Forms.Button butSua;
		private MaskedTextBox.MaskedTextBox mact;

		public frmTimct(AccessData acc,string mmyy,string ngay,string _chuong,string _lk,string _lctug,string _nghiepvu,string _chucnang,int userid,string title,bool admin)
		{
			//
			// Required for Windows Form Designer support
			//			
			InitializeComponent();			
			a=acc;i_userid=userid;s_mmyy=mmyy;s_ngay=ngay;
			s_chuong=_chuong;s_lk=_lk;s_lctug=_lctug;s_nghiepvu=_nghiepvu;
			bAdmin=admin;this.Text=title;s_chucnang=_chucnang;
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmTimct));
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label9 = new System.Windows.Forms.Label();
            this.label10 = new System.Windows.Forms.Label();
            this.tu = new MaskedBox.MaskedBox();
            this.ngaygs = new MaskedBox.MaskedBox();
            this.tknoa = new System.Windows.Forms.TextBox();
            this.ttknoa = new System.Windows.Forms.TextBox();
            this.hoatdong = new System.Windows.Forms.ComboBox();
            this.lctug = new System.Windows.Forms.ComboBox();
            this.listdt = new LibList.List();
            this.dataGrid1 = new System.Windows.Forms.DataGrid();
            this.butTim = new System.Windows.Forms.Button();
            this.butIn = new System.Windows.Forms.Button();
            this.butKetthuc = new System.Windows.Forms.Button();
            this.soctg = new MaskedTextBox.MaskedTextBox();
            this.ctgs = new MaskedTextBox.MaskedTextBox();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.label45 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.chuong = new System.Windows.Forms.ComboBox();
            this.label7 = new System.Windows.Forms.Label();
            this.nghiepvu = new System.Windows.Forms.ComboBox();
            this.tcnkp = new System.Windows.Forms.ComboBox();
            this.label11 = new System.Windows.Forms.Label();
            this.ttkcoa = new System.Windows.Forms.TextBox();
            this.tkcoa = new System.Windows.Forms.TextBox();
            this.tendt = new System.Windows.Forms.TextBox();
            this.madt = new System.Windows.Forms.TextBox();
            this.label27 = new System.Windows.Forms.Label();
            this.liststk = new LibList.List();
            this.chkXml = new System.Windows.Forms.CheckBox();
            this.nhom = new System.Windows.Forms.ComboBox();
            this.label28 = new System.Windows.Forms.Label();
            this.label29 = new System.Windows.Forms.Label();
            this.mact = new MaskedTextBox.MaskedTextBox();
            this.chucnang = new System.Windows.Forms.ComboBox();
            this.label12 = new System.Windows.Forms.Label();
            this.den = new MaskedBox.MaskedBox();
            this.label13 = new System.Windows.Forms.Label();
            this.dataGrid2 = new System.Windows.Forms.DataGrid();
            this.kmco3 = new System.Windows.Forms.ComboBox();
            this.kmco2 = new System.Windows.Forms.ComboBox();
            this.kmco4 = new System.Windows.Forms.ComboBox();
            this.label36 = new System.Windows.Forms.Label();
            this.label39 = new System.Windows.Forms.Label();
            this.label40 = new System.Windows.Forms.Label();
            this.kmno3 = new System.Windows.Forms.ComboBox();
            this.kmno2 = new System.Windows.Forms.ComboBox();
            this.kmno4 = new System.Windows.Forms.ComboBox();
            this.label32 = new System.Windows.Forms.Label();
            this.label31 = new System.Windows.Forms.Label();
            this.label30 = new System.Windows.Forms.Label();
            this.kmco = new System.Windows.Forms.ComboBox();
            this.label18 = new System.Windows.Forms.Label();
            this.kmno = new System.Windows.Forms.ComboBox();
            this.label17 = new System.Windows.Forms.Label();
            this.lk = new System.Windows.Forms.ComboBox();
            this.label50 = new System.Windows.Forms.Label();
            this.label15 = new System.Windows.Forms.Label();
            this.tt = new System.Windows.Forms.ComboBox();
            this.st1 = new MaskedTextBox.MaskedTextBox();
            this.st2 = new MaskedTextBox.MaskedTextBox();
            this.soctg2 = new MaskedTextBox.MaskedTextBox();
            this.chkNoco = new System.Windows.Forms.CheckBox();
            this.butSua = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).BeginInit();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(352, 26);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(56, 23);
            this.label1.TabIndex = 4;
            this.label1.Text = "Số phiếu :";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label2
            // 
            this.label2.Location = new System.Drawing.Point(16, 2);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(64, 23);
            this.label2.TabIndex = 70;
            this.label2.Text = "Từ ngày :";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label3
            // 
            this.label3.Location = new System.Drawing.Point(520, 48);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(96, 23);
            this.label3.TabIndex = 11;
            this.label3.Text = "Chứng từ ghi sổ :";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label4
            // 
            this.label4.Location = new System.Drawing.Point(312, 48);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(96, 23);
            this.label4.TabIndex = 9;
            this.label4.Text = "Ngày hạch toán :";
            this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label5
            // 
            this.label5.Location = new System.Drawing.Point(3, 113);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(80, 23);
            this.label5.TabIndex = 28;
            this.label5.Text = "Tài khoản nợ :";
            this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label9
            // 
            this.label9.Location = new System.Drawing.Point(170, 24);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(64, 23);
            this.label9.TabIndex = 128;
            this.label9.Text = "Hoạt động :";
            this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label10
            // 
            this.label10.Location = new System.Drawing.Point(568, 0);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(48, 23);
            this.label10.TabIndex = 2;
            this.label10.Text = "Loại :";
            this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // tu
            // 
            this.tu.BackColor = System.Drawing.SystemColors.HighlightText;
            this.tu.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.tu.Location = new System.Drawing.Point(83, 3);
            this.tu.Mask = "##/##/####";
            this.tu.MaxLength = 10;
            this.tu.Name = "tu";
            this.tu.Size = new System.Drawing.Size(64, 21);
            this.tu.TabIndex = 0;
            this.tu.Text = "  /  /    ";
            this.tu.Validated += new System.EventHandler(this.tu_Validated);
            // 
            // ngaygs
            // 
            this.ngaygs.BackColor = System.Drawing.SystemColors.HighlightText;
            this.ngaygs.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ngaygs.Location = new System.Drawing.Point(408, 48);
            this.ngaygs.Mask = "##/##/####";
            this.ngaygs.MaxLength = 10;
            this.ngaygs.Name = "ngaygs";
            this.ngaygs.Size = new System.Drawing.Size(64, 21);
            this.ngaygs.TabIndex = 12;
            this.ngaygs.Text = "  /  /    ";
            this.ngaygs.Validated += new System.EventHandler(this.ngaygs_Validated);
            // 
            // tknoa
            // 
            this.tknoa.BackColor = System.Drawing.SystemColors.HighlightText;
            this.tknoa.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.tknoa.Location = new System.Drawing.Point(83, 116);
            this.tknoa.Name = "tknoa";
            this.tknoa.Size = new System.Drawing.Size(109, 21);
            this.tknoa.TabIndex = 20;
            this.tknoa.TextChanged += new System.EventHandler(this.tknoa_TextChanged);
            this.tknoa.Validated += new System.EventHandler(this.tknoa_Validated);
            this.tknoa.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tknoa_KeyDown);
            // 
            // ttknoa
            // 
            this.ttknoa.BackColor = System.Drawing.SystemColors.HighlightText;
            this.ttknoa.Enabled = false;
            this.ttknoa.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ttknoa.Location = new System.Drawing.Point(193, 116);
            this.ttknoa.Name = "ttknoa";
            this.ttknoa.Size = new System.Drawing.Size(255, 21);
            this.ttknoa.TabIndex = 21;
            // 
            // hoatdong
            // 
            this.hoatdong.BackColor = System.Drawing.SystemColors.HighlightText;
            this.hoatdong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.hoatdong.Location = new System.Drawing.Point(234, 26);
            this.hoatdong.Name = "hoatdong";
            this.hoatdong.Size = new System.Drawing.Size(94, 21);
            this.hoatdong.TabIndex = 5;
            this.hoatdong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // lctug
            // 
            this.lctug.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.lctug.BackColor = System.Drawing.SystemColors.HighlightText;
            this.lctug.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lctug.Location = new System.Drawing.Point(616, 3);
            this.lctug.Name = "lctug";
            this.lctug.Size = new System.Drawing.Size(240, 21);
            this.lctug.TabIndex = 3;
            this.lctug.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // listdt
            // 
            this.listdt.BackColor = System.Drawing.SystemColors.Info;
            this.listdt.ColumnCount = 0;
            this.listdt.Location = new System.Drawing.Point(578, 552);
            this.listdt.MatchBufferTimeOut = 1000;
            this.listdt.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listdt.Name = "listdt";
            this.listdt.Size = new System.Drawing.Size(75, 17);
            this.listdt.TabIndex = 100;
            this.listdt.TextIndex = -1;
            this.listdt.TextMember = null;
            this.listdt.ValueIndex = -1;
            this.listdt.Visible = false;
            // 
            // dataGrid1
            // 
            this.dataGrid1.AlternatingBackColor = System.Drawing.Color.Lavender;
            this.dataGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.dataGrid1.BackColor = System.Drawing.Color.WhiteSmoke;
            this.dataGrid1.BackgroundColor = System.Drawing.SystemColors.Control;
            this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.dataGrid1.CaptionBackColor = System.Drawing.SystemColors.Control;
            this.dataGrid1.CaptionFont = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dataGrid1.CaptionForeColor = System.Drawing.Color.Red;
            this.dataGrid1.CaptionText = "xxxxxxx";
            this.dataGrid1.DataMember = "";
            this.dataGrid1.FlatMode = true;
            this.dataGrid1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dataGrid1.ForeColor = System.Drawing.Color.MidnightBlue;
            this.dataGrid1.GridLineColor = System.Drawing.Color.Gainsboro;
            this.dataGrid1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;
            this.dataGrid1.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
            this.dataGrid1.HeaderForeColor = System.Drawing.Color.WhiteSmoke;
            this.dataGrid1.LinkColor = System.Drawing.Color.Teal;
            this.dataGrid1.Location = new System.Drawing.Point(8, 368);
            this.dataGrid1.Name = "dataGrid1";
            this.dataGrid1.ParentRowsBackColor = System.Drawing.Color.Gainsboro;
            this.dataGrid1.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
            this.dataGrid1.ReadOnly = true;
            this.dataGrid1.RowHeaderWidth = 10;
            this.dataGrid1.SelectionBackColor = System.Drawing.Color.CadetBlue;
            this.dataGrid1.SelectionForeColor = System.Drawing.Color.WhiteSmoke;
            this.dataGrid1.Size = new System.Drawing.Size(848, 149);
            this.dataGrid1.TabIndex = 90;
            // 
            // butTim
            // 
            this.butTim.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.butTim.Image = ((System.Drawing.Image)(resources.GetObject("butTim.Image")));
            this.butTim.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butTim.Location = new System.Drawing.Point(303, 528);
            this.butTim.Name = "butTim";
            this.butTim.Size = new System.Drawing.Size(60, 25);
            this.butTim.TabIndex = 84;
            this.butTim.Text = "      &Tìm";
            this.butTim.Click += new System.EventHandler(this.butMoi_Click);
            // 
            // butIn
            // 
            this.butIn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.butIn.Image = ((System.Drawing.Image)(resources.GetObject("butIn.Image")));
            this.butIn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butIn.Location = new System.Drawing.Point(366, 528);
            this.butIn.Name = "butIn";
            this.butIn.Size = new System.Drawing.Size(60, 25);
            this.butIn.TabIndex = 87;
            this.butIn.Text = "      &In";
            this.butIn.Click += new System.EventHandler(this.butIn_Click);
            // 
            // butKetthuc
            // 
            this.butKetthuc.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.butKetthuc.Image = ((System.Drawing.Image)(resources.GetObject("butKetthuc.Image")));
            this.butKetthuc.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butKetthuc.Location = new System.Drawing.Point(492, 528);
            this.butKetthuc.Name = "butKetthuc";
            this.butKetthuc.Size = new System.Drawing.Size(70, 25);
            this.butKetthuc.TabIndex = 88;
            this.butKetthuc.Text = "&Kết thúc";
            this.butKetthuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.butKetthuc.Click += new System.EventHandler(this.butKetthuc_Click);
            // 
            // soctg
            // 
            this.soctg.BackColor = System.Drawing.SystemColors.HighlightText;
            this.soctg.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.soctg.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.soctg.Location = new System.Drawing.Point(408, 26);
            this.soctg.Masked = MaskedTextBox.MaskedTextBox.Mask.None;
            this.soctg.Name = "soctg";
            this.soctg.Size = new System.Drawing.Size(75, 21);
            this.soctg.TabIndex = 6;
            // 
            // ctgs
            // 
            this.ctgs.BackColor = System.Drawing.SystemColors.HighlightText;
            this.ctgs.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ctgs.Location = new System.Drawing.Point(616, 48);
            this.ctgs.Masked = MaskedTextBox.MaskedTextBox.Mask.None;
            this.ctgs.MaxLength = 50;
            this.ctgs.Name = "ctgs";
            this.ctgs.Size = new System.Drawing.Size(96, 21);
            this.ctgs.TabIndex = 13;
            // 
            // label45
            // 
            this.label45.Location = new System.Drawing.Point(568, 70);
            this.label45.Name = "label45";
            this.label45.Size = new System.Drawing.Size(224, 23);
            this.label45.TabIndex = 17;
            this.label45.Text = "Tính chất nguồn kinh phí :";
            this.label45.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolTip1.SetToolTip(this.label45, "Tính chất nguồn kinh phí");
            // 
            // label6
            // 
            this.label6.Location = new System.Drawing.Point(24, 70);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(56, 23);
            this.label6.TabIndex = 13;
            this.label6.Text = "Chương :";
            this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // chuong
            // 
            this.chuong.BackColor = System.Drawing.SystemColors.HighlightText;
            this.chuong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.chuong.Location = new System.Drawing.Point(83, 71);
            this.chuong.Name = "chuong";
            this.chuong.Size = new System.Drawing.Size(237, 21);
            this.chuong.TabIndex = 15;
            this.chuong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // label7
            // 
            this.label7.Location = new System.Drawing.Point(344, 70);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(64, 23);
            this.label7.TabIndex = 15;
            this.label7.Text = "Nghiệp vụ :";
            this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // nghiepvu
            // 
            this.nghiepvu.BackColor = System.Drawing.SystemColors.HighlightText;
            this.nghiepvu.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.nghiepvu.Location = new System.Drawing.Point(408, 71);
            this.nghiepvu.Name = "nghiepvu";
            this.nghiepvu.Size = new System.Drawing.Size(240, 21);
            this.nghiepvu.TabIndex = 16;
            this.nghiepvu.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // tcnkp
            // 
            this.tcnkp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.tcnkp.BackColor = System.Drawing.SystemColors.HighlightText;
            this.tcnkp.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.tcnkp.Location = new System.Drawing.Point(792, 71);
            this.tcnkp.Name = "tcnkp";
            this.tcnkp.Size = new System.Drawing.Size(64, 21);
            this.tcnkp.TabIndex = 17;
            this.tcnkp.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // label11
            // 
            this.label11.Location = new System.Drawing.Point(456, 113);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(48, 23);
            this.label11.TabIndex = 31;
            this.label11.Text = "TK có :";
            this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // ttkcoa
            // 
            this.ttkcoa.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.ttkcoa.BackColor = System.Drawing.SystemColors.HighlightText;
            this.ttkcoa.Enabled = false;
            this.ttkcoa.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ttkcoa.Location = new System.Drawing.Point(578, 116);
            this.ttkcoa.Name = "ttkcoa";
            this.ttkcoa.Size = new System.Drawing.Size(278, 21);
            this.ttkcoa.TabIndex = 23;
            // 
            // tkcoa
            // 
            this.tkcoa.BackColor = System.Drawing.SystemColors.HighlightText;
            this.tkcoa.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.tkcoa.Location = new System.Drawing.Point(504, 116);
            this.tkcoa.Name = "tkcoa";
            this.tkcoa.Size = new System.Drawing.Size(72, 21);
            this.tkcoa.TabIndex = 22;
            this.tkcoa.TextChanged += new System.EventHandler(this.tkcoa_TextChanged);
            this.tkcoa.Validated += new System.EventHandler(this.tkcoa_Validated);
            this.tkcoa.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tknoa_KeyDown);
            // 
            // tendt
            // 
            this.tendt.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.tendt.BackColor = System.Drawing.SystemColors.HighlightText;
            this.tendt.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.tendt.Location = new System.Drawing.Point(193, 93);
            this.tendt.Name = "tendt";
            this.tendt.Size = new System.Drawing.Size(663, 21);
            this.tendt.TabIndex = 19;
            this.tendt.TextChanged += new System.EventHandler(this.tendt_TextChanged);
            this.tendt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tendt_KeyDown);
            // 
            // madt
            // 
            this.madt.BackColor = System.Drawing.SystemColors.HighlightText;
            this.madt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.madt.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.madt.Location = new System.Drawing.Point(83, 93);
            this.madt.Name = "madt";
            this.madt.Size = new System.Drawing.Size(109, 21);
            this.madt.TabIndex = 18;
            this.madt.Validated += new System.EventHandler(this.madt_Validated);
            this.madt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // label27
            // 
            this.label27.Location = new System.Drawing.Point(0, 92);
            this.label27.Name = "label27";
            this.label27.Size = new System.Drawing.Size(80, 23);
            this.label27.TabIndex = 23;
            this.label27.Text = "Đối tượng :";
            this.label27.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // liststk
            // 
            this.liststk.BackColor = System.Drawing.SystemColors.Info;
            this.liststk.ColumnCount = 0;
            this.liststk.Location = new System.Drawing.Point(664, 552);
            this.liststk.MatchBufferTimeOut = 1000;
            this.liststk.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.liststk.Name = "liststk";
            this.liststk.Size = new System.Drawing.Size(75, 17);
            this.liststk.TabIndex = 102;
            this.liststk.TextIndex = -1;
            this.liststk.TextMember = null;
            this.liststk.ValueIndex = -1;
            this.liststk.Visible = false;
            // 
            // chkXml
            // 
            this.chkXml.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.chkXml.Location = new System.Drawing.Point(8, 544);
            this.chkXml.Name = "chkXml";
            this.chkXml.Size = new System.Drawing.Size(88, 16);
            this.chkXml.TabIndex = 106;
            this.chkXml.Text = "Xuất ra XML";
            this.chkXml.Visible = false;
            // 
            // nhom
            // 
            this.nhom.BackColor = System.Drawing.SystemColors.HighlightText;
            this.nhom.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.nhom.Location = new System.Drawing.Point(83, 26);
            this.nhom.Name = "nhom";
            this.nhom.Size = new System.Drawing.Size(93, 21);
            this.nhom.TabIndex = 4;
            this.nhom.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // label28
            // 
            this.label28.Location = new System.Drawing.Point(24, 26);
            this.label28.Name = "label28";
            this.label28.Size = new System.Drawing.Size(56, 23);
            this.label28.TabIndex = 129;
            this.label28.Text = "Nhóm :";
            this.label28.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label29
            // 
            this.label29.Location = new System.Drawing.Point(696, 48);
            this.label29.Name = "label29";
            this.label29.Size = new System.Drawing.Size(96, 23);
            this.label29.TabIndex = 130;
            this.label29.Text = "Kèm Chứng từ :";
            this.label29.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // mact
            // 
            this.mact.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.mact.BackColor = System.Drawing.SystemColors.HighlightText;
            this.mact.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.mact.Location = new System.Drawing.Point(792, 48);
            this.mact.Masked = MaskedTextBox.MaskedTextBox.Mask.None;
            this.mact.MaxLength = 10;
            this.mact.Name = "mact";
            this.mact.Size = new System.Drawing.Size(64, 21);
            this.mact.TabIndex = 14;
            // 
            // chucnang
            // 
            this.chucnang.BackColor = System.Drawing.SystemColors.HighlightText;
            this.chucnang.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.chucnang.Location = new System.Drawing.Point(408, 3);
            this.chucnang.Name = "chucnang";
            this.chucnang.Size = new System.Drawing.Size(152, 21);
            this.chucnang.TabIndex = 2;
            this.chucnang.SelectedIndexChanged += new System.EventHandler(this.chucnang_SelectedIndexChanged);
            this.chucnang.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // label12
            // 
            this.label12.Location = new System.Drawing.Point(336, 0);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(72, 23);
            this.label12.TabIndex = 131;
            this.label12.Text = "Chức năng :";
            this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // den
            // 
            this.den.BackColor = System.Drawing.SystemColors.HighlightText;
            this.den.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.den.Location = new System.Drawing.Point(234, 3);
            this.den.Mask = "##/##/####";
            this.den.MaxLength = 10;
            this.den.Name = "den";
            this.den.Size = new System.Drawing.Size(64, 21);
            this.den.TabIndex = 1;
            this.den.Text = "  /  /    ";
            this.den.Validated += new System.EventHandler(this.den_Validated);
            // 
            // label13
            // 
            this.label13.Location = new System.Drawing.Point(170, 2);
            this.label13.Name = "label13";
            this.label13.Size = new System.Drawing.Size(64, 23);
            this.label13.TabIndex = 134;
            this.label13.Text = "đến :";
            this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // dataGrid2
            // 
            this.dataGrid2.AlternatingBackColor = System.Drawing.Color.Lavender;
            this.dataGrid2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.dataGrid2.BackColor = System.Drawing.Color.WhiteSmoke;
            this.dataGrid2.BackgroundColor = System.Drawing.SystemColors.Control;
            this.dataGrid2.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.dataGrid2.CaptionBackColor = System.Drawing.SystemColors.Control;
            this.dataGrid2.CaptionFont = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dataGrid2.CaptionForeColor = System.Drawing.Color.MidnightBlue;
            this.dataGrid2.DataMember = "";
            this.dataGrid2.FlatMode = true;
            this.dataGrid2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dataGrid2.ForeColor = System.Drawing.Color.MidnightBlue;
            this.dataGrid2.GridLineColor = System.Drawing.Color.Gainsboro;
            this.dataGrid2.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;
            this.dataGrid2.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
            this.dataGrid2.HeaderForeColor = System.Drawing.Color.WhiteSmoke;
            this.dataGrid2.LinkColor = System.Drawing.Color.Teal;
            this.dataGrid2.Location = new System.Drawing.Point(8, 143);
            this.dataGrid2.Name = "dataGrid2";
            this.dataGrid2.ParentRowsBackColor = System.Drawing.Color.Gainsboro;
            this.dataGrid2.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
            this.dataGrid2.ReadOnly = true;
            this.dataGrid2.RowHeaderWidth = 10;
            this.dataGrid2.SelectionBackColor = System.Drawing.Color.CadetBlue;
            this.dataGrid2.SelectionForeColor = System.Drawing.Color.WhiteSmoke;
            this.dataGrid2.Size = new System.Drawing.Size(848, 219);
            this.dataGrid2.TabIndex = 135;
            this.dataGrid2.CurrentCellChanged += new System.EventHandler(this.dataGrid2_CurrentCellChanged);
            // 
            // kmco3
            // 
            this.kmco3.BackColor = System.Drawing.SystemColors.HighlightText;
            this.kmco3.Enabled = false;
            this.kmco3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.kmco3.Location = new System.Drawing.Point(763, 548);
            this.kmco3.Name = "kmco3";
            this.kmco3.Size = new System.Drawing.Size(10, 21);
            this.kmco3.TabIndex = 30;
            this.kmco3.Visible = false;
            this.kmco3.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // kmco2
            // 
            this.kmco2.BackColor = System.Drawing.SystemColors.HighlightText;
            this.kmco2.Enabled = false;
            this.kmco2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.kmco2.Location = new System.Drawing.Point(763, 548);
            this.kmco2.Name = "kmco2";
            this.kmco2.Size = new System.Drawing.Size(10, 21);
            this.kmco2.TabIndex = 29;
            this.kmco2.Visible = false;
            this.kmco2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // kmco4
            // 
            this.kmco4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.kmco4.BackColor = System.Drawing.SystemColors.HighlightText;
            this.kmco4.Enabled = false;
            this.kmco4.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.kmco4.Location = new System.Drawing.Point(763, 548);
            this.kmco4.Name = "kmco4";
            this.kmco4.Size = new System.Drawing.Size(10, 21);
            this.kmco4.TabIndex = 31;
            this.kmco4.Visible = false;
            this.kmco4.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // label36
            // 
            this.label36.Enabled = false;
            this.label36.Location = new System.Drawing.Point(758, 552);
            this.label36.Name = "label36";
            this.label36.Size = new System.Drawing.Size(10, 19);
            this.label36.TabIndex = 157;
            this.label36.Text = "K mục 4 :";
            this.label36.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.label36.Visible = false;
            // 
            // label39
            // 
            this.label39.Enabled = false;
            this.label39.Location = new System.Drawing.Point(757, 552);
            this.label39.Name = "label39";
            this.label39.Size = new System.Drawing.Size(10, 19);
            this.label39.TabIndex = 156;
            this.label39.Text = "K mục 3 :";
            this.label39.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.label39.Visible = false;
            // 
            // label40
            // 
            this.label40.Enabled = false;
            this.label40.Location = new System.Drawing.Point(758, 550);
            this.label40.Name = "label40";
            this.label40.Size = new System.Drawing.Size(10, 19);
            this.label40.TabIndex = 155;
            this.label40.Text = "K mục 2 :";
            this.label40.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.label40.Visible = false;
            // 
            // kmno3
            // 
            this.kmno3.BackColor = System.Drawing.SystemColors.HighlightText;
            this.kmno3.Enabled = false;
            this.kmno3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.kmno3.Location = new System.Drawing.Point(757, 548);
            this.kmno3.Name = "kmno3";
            this.kmno3.Size = new System.Drawing.Size(10, 21);
            this.kmno3.TabIndex = 26;
            this.kmno3.Visible = false;
            this.kmno3.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // kmno2
            // 
            this.kmno2.BackColor = System.Drawing.SystemColors.HighlightText;
            this.kmno2.Enabled = false;
            this.kmno2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.kmno2.Location = new System.Drawing.Point(763, 548);
            this.kmno2.Name = "kmno2";
            this.kmno2.Size = new System.Drawing.Size(10, 21);
            this.kmno2.TabIndex = 25;
            this.kmno2.Visible = false;
            this.kmno2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // kmno4
            // 
            this.kmno4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.kmno4.BackColor = System.Drawing.SystemColors.HighlightText;
            this.kmno4.Enabled = false;
            this.kmno4.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.kmno4.Location = new System.Drawing.Point(761, 548);
            this.kmno4.Name = "kmno4";
            this.kmno4.Size = new System.Drawing.Size(12, 21);
            this.kmno4.TabIndex = 27;
            this.kmno4.Visible = false;
            this.kmno4.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // label32
            // 
            this.label32.Enabled = false;
            this.label32.Location = new System.Drawing.Point(763, 546);
            this.label32.Name = "label32";
            this.label32.Size = new System.Drawing.Size(10, 23);
            this.label32.TabIndex = 154;
            this.label32.Text = "K mục 4 :";
            this.label32.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.label32.Visible = false;
            // 
            // label31
            // 
            this.label31.Enabled = false;
            this.label31.Location = new System.Drawing.Point(773, 546);
            this.label31.Name = "label31";
            this.label31.Size = new System.Drawing.Size(10, 23);
            this.label31.TabIndex = 153;
            this.label31.Text = "K mục 3 :";
            this.label31.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.label31.Visible = false;
            // 
            // label30
            // 
            this.label30.Enabled = false;
            this.label30.Location = new System.Drawing.Point(758, 546);
            this.label30.Name = "label30";
            this.label30.Size = new System.Drawing.Size(10, 23);
            this.label30.TabIndex = 152;
            this.label30.Text = "K mục 2 :";
            this.label30.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.label30.Visible = false;
            // 
            // kmco
            // 
            this.kmco.BackColor = System.Drawing.SystemColors.HighlightText;
            this.kmco.Enabled = false;
            this.kmco.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.kmco.Location = new System.Drawing.Point(763, 548);
            this.kmco.Name = "kmco";
            this.kmco.Size = new System.Drawing.Size(10, 21);
            this.kmco.TabIndex = 28;
            this.kmco.Visible = false;
            this.kmco.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // label18
            // 
            this.label18.Enabled = false;
            this.label18.Location = new System.Drawing.Point(757, 552);
            this.label18.Name = "label18";
            this.label18.Size = new System.Drawing.Size(10, 19);
            this.label18.TabIndex = 151;
            this.label18.Text = "K mục có 1 :";
            this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.label18.Visible = false;
            // 
            // kmno
            // 
            this.kmno.BackColor = System.Drawing.SystemColors.HighlightText;
            this.kmno.Enabled = false;
            this.kmno.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.kmno.Location = new System.Drawing.Point(773, 548);
            this.kmno.Name = "kmno";
            this.kmno.Size = new System.Drawing.Size(10, 21);
            this.kmno.TabIndex = 24;
            this.kmno.Visible = false;
            this.kmno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // label17
            // 
            this.label17.Enabled = false;
            this.label17.Location = new System.Drawing.Point(745, 550);
            this.label17.Name = "label17";
            this.label17.Size = new System.Drawing.Size(48, 23);
            this.label17.TabIndex = 150;
            this.label17.Text = "K mục nợ 1 :";
            this.label17.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.label17.Visible = false;
            this.label17.Click += new System.EventHandler(this.label17_Click);
            // 
            // lk
            // 
            this.lk.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.lk.BackColor = System.Drawing.SystemColors.HighlightText;
            this.lk.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lk.Location = new System.Drawing.Point(616, 26);
            this.lk.Name = "lk";
            this.lk.Size = new System.Drawing.Size(240, 21);
            this.lk.TabIndex = 8;
            this.lk.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // label50
            // 
            this.label50.Location = new System.Drawing.Point(544, 26);
            this.label50.Name = "label50";
            this.label50.Size = new System.Drawing.Size(72, 23);
            this.label50.TabIndex = 159;
            this.label50.Text = "L. khoản :";
            this.label50.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label15
            // 
            this.label15.Location = new System.Drawing.Point(24, 48);
            this.label15.Name = "label15";
            this.label15.Size = new System.Drawing.Size(56, 23);
            this.label15.TabIndex = 164;
            this.label15.Text = "Số tiền :";
            this.label15.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // tt
            // 
            this.tt.BackColor = System.Drawing.SystemColors.HighlightText;
            this.tt.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.tt.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.tt.Items.AddRange(new object[] {
            "=",
            ">=",
            "<=",
            "từ .. đến"});
            this.tt.Location = new System.Drawing.Point(83, 48);
            this.tt.Name = "tt";
            this.tt.Size = new System.Drawing.Size(61, 21);
            this.tt.TabIndex = 9;
            this.tt.SelectedIndexChanged += new System.EventHandler(this.tt_SelectedIndexChanged);
            this.tt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
            // 
            // st1
            // 
            this.st1.BackColor = System.Drawing.SystemColors.HighlightText;
            this.st1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.st1.Location = new System.Drawing.Point(144, 48);
            this.st1.Masked = MaskedTextBox.MaskedTextBox.Mask.Decimal;
            this.st1.Name = "st1";
            this.st1.Size = new System.Drawing.Size(87, 21);
            this.st1.TabIndex = 10;
            this.st1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            // 
            // st2
            // 
            this.st2.BackColor = System.Drawing.SystemColors.HighlightText;
            this.st2.Enabled = false;
            this.st2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.st2.Location = new System.Drawing.Point(233, 48);
            this.st2.Masked = MaskedTextBox.MaskedTextBox.Mask.Decimal;
            this.st2.Name = "st2";
            this.st2.Size = new System.Drawing.Size(87, 21);
            this.st2.TabIndex = 11;
            this.st2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            // 
            // soctg2
            // 
            this.soctg2.BackColor = System.Drawing.SystemColors.HighlightText;
            this.soctg2.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.soctg2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.soctg2.Location = new System.Drawing.Point(484, 26);
            this.soctg2.Masked = MaskedTextBox.MaskedTextBox.Mask.None;
            this.soctg2.Name = "soctg2";
            this.soctg2.Size = new System.Drawing.Size(76, 21);
            this.soctg2.TabIndex = 7;
            // 
            // chkNoco
            // 
            this.chkNoco.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.chkNoco.Location = new System.Drawing.Point(8, 524);
            this.chkNoco.Name = "chkNoco";
            this.chkNoco.Size = new System.Drawing.Size(184, 16);
            this.chkNoco.TabIndex = 165;
            this.chkNoco.Text = "Tài khoản nợ hoặc tài khoản có";
            // 
            // butSua
            // 
            this.butSua.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.butSua.Image = ((System.Drawing.Image)(resources.GetObject("butSua.Image")));
            this.butSua.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butSua.Location = new System.Drawing.Point(429, 528);
            this.butSua.Name = "butSua";
            this.butSua.Size = new System.Drawing.Size(60, 25);
            this.butSua.TabIndex = 166;
            this.butSua.Text = "      &Sửa";
            this.butSua.Click += new System.EventHandler(this.butSua_Click);
            // 
            // frmTimct
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(864, 573);
            this.Controls.Add(this.butSua);
            this.Controls.Add(this.chkNoco);
            this.Controls.Add(this.nghiepvu);
            this.Controls.Add(this.soctg2);
            this.Controls.Add(this.st2);
            this.Controls.Add(this.st1);
            this.Controls.Add(this.tt);
            this.Controls.Add(this.label15);
            this.Controls.Add(this.soctg);
            this.Controls.Add(this.lk);
            this.Controls.Add(this.label50);
            this.Controls.Add(this.kmco2);
            this.Controls.Add(this.kmno2);
            this.Controls.Add(this.kmco3);
            this.Controls.Add(this.kmco);
            this.Controls.Add(this.kmco4);
            this.Controls.Add(this.label36);
            this.Controls.Add(this.label39);
            this.Controls.Add(this.label40);
            this.Controls.Add(this.label18);
            this.Controls.Add(this.kmno3);
            this.Controls.Add(this.kmno4);
            this.Controls.Add(this.label32);
            this.Controls.Add(this.label31);
            this.Controls.Add(this.label30);
            this.Controls.Add(this.kmno);
            this.Controls.Add(this.label17);
            this.Controls.Add(this.tcnkp);
            this.Controls.Add(this.den);
            this.Controls.Add(this.label13);
            this.Controls.Add(this.chucnang);
            this.Controls.Add(this.label12);
            this.Controls.Add(this.ctgs);
            this.Controls.Add(this.mact);
            this.Controls.Add(this.label29);
            this.Controls.Add(this.nhom);
            this.Controls.Add(this.label28);
            this.Controls.Add(this.chkXml);
            this.Controls.Add(this.liststk);
            this.Controls.Add(this.tendt);
            this.Controls.Add(this.madt);
            this.Controls.Add(this.label27);
            this.Controls.Add(this.ttkcoa);
            this.Controls.Add(this.tkcoa);
            this.Controls.Add(this.label11);
            this.Controls.Add(this.label45);
            this.Controls.Add(this.chuong);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.ttknoa);
            this.Controls.Add(this.butKetthuc);
            this.Controls.Add(this.butIn);
            this.Controls.Add(this.butTim);
            this.Controls.Add(this.lctug);
            this.Controls.Add(this.hoatdong);
            this.Controls.Add(this.label10);
            this.Controls.Add(this.label9);
            this.Controls.Add(this.dataGrid1);
            this.Controls.Add(this.listdt);
            this.Controls.Add(this.tknoa);
            this.Controls.Add(this.ngaygs);
            this.Controls.Add(this.tu);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.dataGrid2);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "frmTimct";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Phiếu nhập chứng từ";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.Load += new System.EventHandler(this.frmTimct_Load);
            this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.frmTimct_MouseMove);
            ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		private void frmTimct_Load(object sender, System.EventArgs e)
		{			
			user=a.user;
			format_sotien=a.format_sotien(0);

			nhom.DisplayMember="TEN";
			nhom.ValueMember="ID";
			nhom.DataSource=a.get_data("select * from a_dmnhombc order by stt").Tables[0];

			hoatdong.DisplayMember="TEN";
			hoatdong.ValueMember="ID";
			hoatdong.DataSource=a.get_data("select * from a_hoatdong where sudung=1 order by stt").Tables[0];

			sql="select * from a_dmchucnang where sudung=1";
			if (s_chucnang!="") sql+=" and id in ("+s_chucnang.Substring(0,s_chucnang.Length-1)+")";
			sql+=" order by stt";
			chucnang.DisplayMember="TEN";
			chucnang.ValueMember="ID";
			chucnang.DataSource=a.get_data(sql).Tables[0];

			lctug.DisplayMember="TEN";
			lctug.ValueMember="ID";

			sql="select * from a_dmchuong where sudung=1";
			if (s_chuong!="") sql+=" and id in ("+s_chuong.Substring(0,s_chuong.Length-1)+")";
			sql+=" order by stt";
			chuong.DisplayMember="TEN";
			chuong.ValueMember="ID";
			chuong.DataSource=a.get_data(sql).Tables[0];

			tcnkp.DisplayMember="TEN";
			tcnkp.ValueMember="ID";
			tcnkp.DataSource=a.get_data("select * from a_dmtcnkp where sudung=1 order by stt").Tables[0];

			sql="select * from a_nghiepvu where sudung=1";
			if (s_nghiepvu!="") sql+=" and id in ("+s_nghiepvu.Substring(0,s_nghiepvu.Length-1)+")";
			sql+=" order by stt";
			nghiepvu.DisplayMember="TEN";
			nghiepvu.ValueMember="ID";
			nghiepvu.DataSource=a.get_data(sql).Tables[0];		
			
			dttk=a.get_data("select stk,ttk,congno,tinhchat,mlns,ctmlns,loaikm,loaikm2,loaikm3,loaikm4,id from a_dmtk where sudung=1 and c=1 order by stk").Tables[0];			

			lk.DisplayMember="LK";
			lk.ValueMember="ID";
			lk.DataSource=a.get_data("select id,lk||' '||tlk as lk,tlk from a_dmlk order by stt").Tables[0];

			kmno.DisplayMember="TEN";
			kmno.ValueMember="ID";

			kmno2.DisplayMember="TEN";
			kmno2.ValueMember="ID";

			kmno3.DisplayMember="TEN";
			kmno3.ValueMember="ID";

			kmno4.DisplayMember="TEN";
			kmno4.ValueMember="ID";

			kmco.DisplayMember="TEN";
			kmco.ValueMember="ID";

			kmco2.DisplayMember="TEN";
			kmco2.ValueMember="ID";

			kmco3.DisplayMember="TEN";
			kmco3.ValueMember="ID";

			kmco4.DisplayMember="TEN";
			kmco4.ValueMember="ID";

			liststk.DisplayMember="STK";
			liststk.ValueMember="TTK";
			liststk.DataSource=dttk;

			dtdt=a.get_data("select mavt,tendt,diachi,loaidt,id from a_dmdt where sudung=1 order by stt").Tables[0];
			listdt.DisplayMember="MAVT";
			listdt.ValueMember="TENDT";
			listdt.DataSource=dtdt;

			load_ct(-1);
			AddGridTableStyle1();
			load_head();
			AddGridTableStyle();

			dtloai1=a.get_data("select * from a_bcnghang order by stt").Tables[0];
			tt.SelectedIndex=0;
		}

		private void load_loai()
		{
			dtloai=a.get_data("select * from a_bcnghang where chucnang="+((chucnang.SelectedIndex!=-1)?int.Parse(chucnang.SelectedValue.ToString()):0)+" order by stt").Tables[0];
			lctug.DataSource=dtloai;
		}
		private void load_grid()
		{
			dataGrid1.DataSource=null;
			sql="select a.id,a.idct,a.stt,a.lk,a.noidung,a.tknoa,a.tkcoa,a.kmno,a.kmco,a.mtmno,a.mtmco,";
			sql+="a.stien,a.nguyente,a.ngoaite,a.tygia,n.ma as mangoaite,a.tonghop,a.mapt,a.ctgs,b.lk as tenlk,";
			sql+="c.stk as stknoa,d.stk as stkcoa,";
			sql+="nvl(e.stk,' ') as stkmtmno,nvl(f.stk,' ') as stkmtmco,nvl(g.ten,' ') as tenpt,";
			sql+="nvl(h.ten,' ') as tenkmno,nvl(i.ten,' ') as tenkmco,";
			sql+="c.mlns as mlnsno,c.ctmlns as ctmlnsno,d.mlns as mlnsco,d.ctmlns as ctmlnsco,";
			sql+="c.loaikm as loaikmno,d.loaikm as loaikmco,a.capphat,j.ten as tencapphat,a.thangqt ";
			sql+=" from a_ctct"+s_mmyy.Substring(2)+" a inner join a_dmlk b on a.lk=b.id ";
			sql+=" left join a_dmtk c on a.tknoa=c.id ";
			sql+=" left join a_dmtk d on a.tkcoa=d.id ";
			sql+=" left join a_dmch e on a.mtmno=e.id ";
			sql+=" left join a_dmch f on a.mtmco=f.id ";
			sql+=" left join a_phantich g on a.mapt=g.id ";
			sql+=" left join a_dmkhoanmuc h on a.kmno=h.id ";
			sql+=" left join a_dmkhoanmuc i on a.kmco=i.id ";
			sql+=" left join a_dmcapphat j on a.capphat=j.id ";
			sql+=" left join a_dmngoaite n on a.ngoaite=n.id ";
			sql+=" where a.idct="+l_id;
			sql+=" order by a.stt";
			dtct=a.get_data(sql).Tables[0];
			dataGrid1.DataSource=dtct;
			try
			{
				dataGrid1.CaptionText=dataGrid2[dataGrid2.CurrentCell.RowNumber,1].ToString().Trim()+" "+dataGrid2[dataGrid2.CurrentCell.RowNumber,2].ToString().Trim()+" "+dataGrid2[dataGrid2.CurrentCell.RowNumber,3].ToString().Trim()+" "+dataGrid2[dataGrid2.CurrentCell.RowNumber,4].ToString().Trim();
			}
			catch{dataGrid1.CaptionText="";}
		}

		public Color MyGetColorRowCol(int row, int col)
		{
			if (this.dataGrid1[row,15].ToString()=="0") return Color.Red;
			else return Color.Black;
		}

		public delegate Color delegateGetColorRowCol(int row, int col);
		public class DataGridColoredTextBoxColumn : DataGridTextBoxColumn
		{
			private delegateGetColorRowCol _getColorRowCol;
			private int _column;
			public DataGridColoredTextBoxColumn(delegateGetColorRowCol getcolorRowCol, int column)
			{
				_getColorRowCol = getcolorRowCol;
				_column = column;
			}
			protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight)
			{
				try
				{
					foreBrush = new SolidBrush(_getColorRowCol(rowNum, this._column));
					//backBrush = new SolidBrush(Color.GhostWhite);
				}
				catch{}
				finally
				{
					base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
				}
			}
		}

		private void AddGridTableStyle()
		{
			DataGridColoredTextBoxColumn TextCol;
			delegateGetColorRowCol de = new delegateGetColorRowCol(MyGetColorRowCol);
			DataGridTableStyle ts =new DataGridTableStyle();
			ts.MappingName = dtct.TableName;
			ts.AlternatingBackColor = Color.Beige;
			ts.BackColor = Color.GhostWhite;
			ts.ForeColor = Color.MidnightBlue;
			ts.GridLineColor = Color.RoyalBlue;
			ts.HeaderBackColor = Color.MidnightBlue;
			ts.HeaderForeColor = Color.Lavender;
			ts.SelectionBackColor = Color.Teal;
			ts.SelectionForeColor = Color.PaleGreen;
			ts.ReadOnly=false;
			ts.RowHeaderWidth=10;
						
			TextCol=new DataGridColoredTextBoxColumn(de, 0);
			TextCol.MappingName = "id";
			TextCol.HeaderText = "";
			TextCol.Width = 0;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 1);
			TextCol.MappingName = "stt";
			TextCol.HeaderText = "STT";
			TextCol.Width = 30;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 2);
			TextCol.MappingName = "tenlk";
			TextCol.HeaderText = "Khoản";
			TextCol.Width = 50;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 3);
			TextCol.MappingName = "noidung";
			TextCol.HeaderText = "Nội dung";
			TextCol.Width = 200;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 4);
			TextCol.MappingName = "stknoa";
			TextCol.HeaderText = "TK Nợ";
			TextCol.Width = 80;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 5);
			TextCol.MappingName = "stkmtmno";
			TextCol.HeaderText = "MTM Nợ";
			TextCol.Width = 50;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 6);
			TextCol.MappingName = "tenkmno";
			TextCol.HeaderText = "KM Nợ";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 7);
			TextCol.MappingName = "stkcoa";
			TextCol.HeaderText = "TK Có";
			TextCol.Width = 80;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 8);
			TextCol.MappingName = "stkmtmco";
			TextCol.HeaderText = "MTM Có";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 9);
			TextCol.MappingName = "tenkmco";
			TextCol.HeaderText = "KM Có";
			TextCol.Width = 50;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 10);
			TextCol.MappingName = "tenpt";
			TextCol.HeaderText = "Phân tích";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 11);
			TextCol.MappingName = "mangoaite";
			TextCol.HeaderText = "Ngoại tệ";
			TextCol.Width = 30;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 12);
			TextCol.MappingName = "tygia";
			TextCol.HeaderText = "Tỷ giá";
			TextCol.Width = 50;
			TextCol.Format="###,###,###";
			TextCol.Alignment=HorizontalAlignment.Right;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 13);
			TextCol.MappingName = "nguyente";
			TextCol.HeaderText = "Nguyên tệ";
			TextCol.Width = 80;
			TextCol.Format=format_sotien;
			TextCol.Alignment=HorizontalAlignment.Right;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 14);
			TextCol.MappingName = "stien";
			TextCol.HeaderText = "Số tiền";
			TextCol.Width = 100;
			TextCol.Format=format_sotien;
			TextCol.Alignment=HorizontalAlignment.Right;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 15);
			TextCol.MappingName = "tonghop";
			TextCol.HeaderText = "";
			TextCol.Width = 0;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);
		}

		private void load_head()
		{
			load_grid();
		}

		private void butKetthuc_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void Filter_dmdt(string ten)
		{
			try
			{
				CurrencyManager cm= (CurrencyManager)BindingContext[listdt.DataSource];
				DataView dv=(DataView)cm.List;
				sql="tendt like '%"+ten.Trim()+"%'";
				dv.RowFilter=sql;				
			}
			catch{}
		}

		private void tendt_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listdt.Focus();
			else if (e.KeyCode==Keys.Enter)
			{
				if (listdt.Visible)	listdt.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void tendt_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==tendt)
			{
				Filter_dmdt(tendt.Text);
				listdt.BrowseToDanhmuc(tendt,madt,tknoa,50);
			}
		}

		private void AddGridTableStyle1()
		{
			DataGridTableStyle ts =new DataGridTableStyle();
			ts.MappingName = dtll.TableName;
			ts.AlternatingBackColor = Color.Beige;
			ts.BackColor = Color.GhostWhite;
			ts.ForeColor = Color.MidnightBlue;
			ts.GridLineColor = Color.RoyalBlue;
			ts.HeaderBackColor = Color.MidnightBlue;
			ts.HeaderForeColor = Color.Lavender;
			ts.SelectionBackColor = Color.Teal;
			ts.SelectionForeColor = Color.PaleGreen;
			ts.ReadOnly=false;
			ts.RowHeaderWidth=10;
						
			DataGridTextBoxColumn TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "id";
			TextCol.HeaderText = "";
			TextCol.Width = 0;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "lctug";
			TextCol.HeaderText = "";
			TextCol.Width = 0;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "thanggs";
			TextCol.HeaderText = "Tháng";
			TextCol.Width = 40;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "tenchucnang";
			TextCol.HeaderText = "Chức năng";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "tenloai";
			TextCol.HeaderText = "Loại";
			TextCol.Width = 200;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "soctg";
			TextCol.HeaderText = "Số CT";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "ngayg";
			TextCol.HeaderText = "Ngày CT";
			TextCol.Width = 65;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "ngaygs";
			TextCol.HeaderText = "Ngày HT";
			TextCol.Width = 65;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "noidung";
			TextCol.HeaderText = "Nội dung";
			TextCol.Width = 250;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "tendt";
			TextCol.HeaderText = "Đối tượng";
			TextCol.Width = 200;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "nguyente";
			TextCol.HeaderText = "Nguyên tệ";
			TextCol.Width = 80;
			TextCol.Alignment=HorizontalAlignment.Right;
			TextCol.Format="###,###,###,###.##";
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "stien";
			TextCol.HeaderText = "Số tiền";
			TextCol.Width = 100;
			TextCol.Alignment=HorizontalAlignment.Right;
			TextCol.Format="###,###,###,###.##";
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "ctgs";
			TextCol.HeaderText = "Chứng từ ghi sổ";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);

			TextCol=new DataGridTextBoxColumn();
			TextCol.MappingName = "mact";
			TextCol.HeaderText = "Kèm theo";
			TextCol.Width = 60;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid2.TableStyles.Add(ts);
		}

		private void load_ct(int id)
		{
			sql="select distinct a.id,a.idbc,c.ten as tenchucnang,d.ten as tenloai,nvl(a.mact,' ') as mact,a.chuong,a.chucnang,a.hoatdong,a.lctug,a.soctg,to_char(a.ngayg,'dd/mm/yyyy') as ngayg,";
			sql+="to_char(a.ngaygs,'dd/mm/yyyy') as ngaygs,a.noidung,a.tknoa,a.tkcoa,";
			sql+="a.loaidt,a.madt,a.stien,a.nguyente,a.thanggs,";
			sql+="a.nghiepvu,a.loaibk,a.tcnkp,a.lanin,a.hopdong,nvl(a.ctgs,' ') as ctgs,a.userid,";
			sql+="e.stk as stknoa,f.stk as stkcoa,e.ttk as ttknoa,f.ttk as ttkcoa,";
			sql+="h.mavt,h.tendt,h.diachi,m.sohd,o.loaihd,o.kyhieu,o.sohd as sobk,";
			sql+="to_char(o.ngayhd,'dd/mm/yyyy') as ngaybk,o.thuexuat,o.tienthue,p.tendt as tendtk,";
			sql+="p.diachi as diachik,q.ten as tenhoatdong,h.sotaikhoan,";
			sql+="nvl(s.account,'') as accountno,";
			sql+="nvl(t.account,'') as accountco,";
			sql+="nvl(s.tennh,'') as tennhno,";
			sql+="nvl(t.tennh,'') as tennhco,";
			sql+="h.masothue";
			sql+=" from a_ct"+s_mmyy.Substring(2)+" a inner join a_dmchuong b on a.chuong=b.id ";
			sql+=" inner join a_dmchucnang c on a.chucnang=c.id ";
			sql+=" inner join a_bcnghang d on a.lctug=d.id ";			
			sql+=" inner join a_ctct"+s_mmyy.Substring(2)+" x on a.id=x.idct";
			sql+=" left join a_dmtk e on a.tknoa=e.id ";
			sql+=" left join a_dmtk f on a.tkcoa=f.id ";
			sql+=" left join a_dmloaidt g on a.loaidt=g.id ";
			sql+=" left join a_dmdt h on a.madt=h.id ";
			sql+=" inner join a_nghiepvu i on a.nghiepvu=i.id ";
			sql+=" left join a_dmloaibk j on a.loaibk=j.id ";
			sql+=" left join a_dmtcnkp k on a.tcnkp=k.id ";
			sql+=" left join a_theodoihd m on a.hopdong=m.id ";
			sql+=" left join a_ctbk"+s_mmyy.Substring(2)+" o on a.id=o.id ";
			sql+=" left join a_ctk"+s_mmyy.Substring(2)+" p on a.id=p.id ";
			sql+=" inner join a_hoatdong q on a.hoatdong=q.id ";
			sql+=" left join a_dmnh s on a.tknoa=s.stk ";
			sql+=" left join a_dmnh t on a.tkcoa=t.stk ";
			if (id==-1) sql+=" where a.id="+id+" and rownum<1";
			else
			{
				sql+=" where a.id>0";
				if (chucnang.SelectedIndex!=-1) sql+=" and a.chucnang="+int.Parse(chucnang.SelectedValue.ToString());
				if (lctug.SelectedIndex!=-1) sql+=" and a.lctug="+int.Parse(lctug.SelectedValue.ToString());
				if (chuong.SelectedIndex!=-1) sql+=" and a.chuong="+int.Parse(chuong.SelectedValue.ToString());
				if (nghiepvu.SelectedIndex!=-1) sql+=" and a.nghiepvu="+int.Parse(nghiepvu.SelectedValue.ToString());
				if (ngaygs.Text!="  /  /    ") sql+=" and to_char(a.ngaygs,'dd/mm/yyyy')='"+ngaygs.Text+"'";
				if (soctg.Text!="" && soctg2.Text!="") sql+=" and a.soctg between '"+soctg.Text+"' and '"+soctg2.Text+"'";
				else if (soctg.Text!="") sql+=" and a.soctg='"+soctg.Text+"'";
				if (ctgs.Text!="") sql+=" and a.ctgs='"+ctgs.Text+"'";
				if (mact.Text!="") sql+=" and a.mact='"+mact.Text+"'";
				if (nhom.SelectedIndex!=-1) sql+=" and a.idbc="+int.Parse(nhom.SelectedValue.ToString());
				if (hoatdong.SelectedIndex!=-1) sql+=" and a.hoatdong="+int.Parse(hoatdong.SelectedValue.ToString());
				if (tcnkp.SelectedIndex!=-1) sql+=" and a.tcnkp="+int.Parse(tcnkp.SelectedValue.ToString());
				if (tu.Text!="" && den.Text!="") sql+=" and to_date(a.ngaygs,'dd/mm/yy') between to_date('"+tu.Text+"','dd/mm/yy') and to_date('"+den.Text+"','dd/mm/yy')";
				if (madt.Text!="") sql+=" and h.mavt='"+madt.Text+"'";
				if (chkNoco.Checked)
				{
					if (tknoa.Text!="") sql+=" and (e.stk='"+tknoa.Text+"' or f.stk='"+tknoa.Text+"')";
					if (tkcoa.Text!="") sql+=" and (f.stk='"+tkcoa.Text+"' or e.stk='"+tkcoa.Text+"')";
				}
				else 
				{
					if (tknoa.Text!="") sql+=" and e.stk='"+tknoa.Text+"'";
					if (tkcoa.Text!="") sql+=" and f.stk='"+tkcoa.Text+"'";
				}
				if (kmno.Enabled && kmno.SelectedIndex!=-1) sql+=" and x.kmno="+long.Parse(kmno.SelectedValue.ToString());
				if (kmno2.Enabled && kmno2.SelectedIndex!=-1) sql+=" and x.kmno2="+long.Parse(kmno2.SelectedValue.ToString());
				if (kmno3.Enabled && kmno3.SelectedIndex!=-1) sql+=" and x.kmno3="+long.Parse(kmno3.SelectedValue.ToString());
                if (kmno4.Enabled && kmno4.SelectedIndex!=-1) sql+=" and x.kmno4="+long.Parse(kmno4.SelectedValue.ToString());
				if (kmco.Enabled && kmco.SelectedIndex!=-1) sql+=" and x.kmco="+long.Parse(kmco.SelectedValue.ToString());
				if (kmco2.Enabled && kmco2.SelectedIndex!=-1) sql+=" and x.kmco2="+long.Parse(kmco2.SelectedValue.ToString());
				if (kmco3.Enabled && kmco3.SelectedIndex!=-1) sql+=" and x.kmco3="+long.Parse(kmco3.SelectedValue.ToString());
				if (kmco4.Enabled && kmco4.SelectedIndex!=-1) sql+=" and x.kmco4="+long.Parse(kmco4.SelectedValue.ToString());
				if (lk.SelectedIndex!=-1) sql+=" and x.lk="+long.Parse(lk.SelectedValue.ToString());
				if (st1.Text!="" && tt.SelectedIndex<3) sql+=" and a.stien"+tt.Text+decimal.Parse(st1.Text);
				else if (st1.Text!="" && st2.Text!="" && tt.SelectedIndex==3) sql+=" and a.stien between "+decimal.Parse(st1.Text)+" and "+decimal.Parse(st2.Text);
			}
			sql+=" order by thanggs,chucnang,lctug,soctg";
			dtll=a.get_data(sql).Tables[0];
			dataGrid2.DataSource=dtll;
		}
		private void butMoi_Click(object sender, System.EventArgs e)
		{
			load_ct(1);
		}

		private void tu_Validated(object sender, System.EventArgs e)
		{
			if (tu.Text=="") return;
			tu.Text=tu.Text.Trim();
			if (!a.bNgay(tu.Text))
			{
				MessageBox.Show("Ngày không hợp lệ !",a.Msg);
				tu.Focus();
				return;
			}
			tu.Text=a.Ktngaygio(tu.Text,10);
		}

		private void den_Validated(object sender, System.EventArgs e)
		{
			if (den.Text=="") return;
			den.Text=den.Text.Trim();
			if (!a.bNgay(den.Text))
			{
				MessageBox.Show("Ngày không hợp lệ !",a.Msg);
				den.Focus();
				return;
			}
			den.Text=a.Ktngaygio(den.Text,10);
			if (tu.Text!=den.Text)
			{
				if (!a.bNgay(den.Text,tu.Text))
				{
					MessageBox.Show("Từ ngày không được lớn hơn đến !",a.Msg);
					tu.Focus();
					return;
				}
			}
		}

		private void ngaygs_Validated(object sender, System.EventArgs e)
		{
			if (ngaygs.Text=="") return;
			ngaygs.Text=ngaygs.Text.Trim();
			if (!a.bNgay(ngaygs.Text))
			{
				MessageBox.Show("Ngày không hợp lệ !",a.Msg);
				ngaygs.Focus();
				return;
			}
			ngaygs.Text=a.Ktngaygio(ngaygs.Text,10);
		}

		private void butIn_Click(object sender, System.EventArgs e)
		{
			try
			{
				DataSet dsxml=new DataSet();				
				l_id=long.Parse(dataGrid2[dataGrid2.CurrentCell.RowNumber,0].ToString());
				int lctug=int.Parse(dataGrid2[dataGrid2.CurrentCell.RowNumber,1].ToString());
				string _mmyy=dataGrid2[dataGrid2.CurrentCell.RowNumber,2].ToString()+s_mmyy.Substring(2);
				string tenfile="";
				DataRow r=a.getrowbyid(dtloai1,"id="+lctug);
				if (r!=null) tenfile=r["tenreport"].ToString();
				if (tenfile!="")
				{
					switch (int.Parse(r["loai"].ToString()))
					{
						case 3: dsxml=a.lenhchi(_mmyy,l_id);break;
						case 4: dsxml=a.phieuthuchi(_mmyy,l_id);break;
						default : dsxml=a.phieulinh(_mmyy,l_id);break;
					}
					/*
					if (chkXml.Checked)
					{
						if (!System.IO.Directory.Exists("..\\xml")) System.IO.Directory.CreateDirectory("..\\xml");
						dsxml.WriteXml("..\\xml\\"+tenfile+".xml",XmlWriteMode.WriteSchema);
					}*/
					frmReport f=new frmReport(a,dsxml,r["ten"].ToString(),tenfile+".rpt");
					f.ShowDialog();
				}
			}
			catch{}
		}

		private void Filter_stk(string ma,LibList.List list)
		{
			try
			{
				CurrencyManager cm= (CurrencyManager)BindingContext[list.DataSource];
				DataView dv=(DataView)cm.List;
				sql="stk like '"+ma.Trim()+"%' or ttk like '%"+ma.Trim()+"%'";
				dv.RowFilter=sql;
			}
			catch{}
		}


		private void hoatdong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter) SendKeys.Send("{Tab}");		
		}

		private void madt_Validated(object sender, System.EventArgs e)
		{
			sql="mavt='"+madt.Text+"'";
			DataRow r=a.getrowbyid(dtdt,sql);
			if (r!=null)
			{
				tendt.Text=r["tendt"].ToString();
			}
			else madt.Text=tendt.Text="";
		}

		private void tknoa_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==tknoa)
			{
				Filter_stk(tknoa.Text,liststk);
				liststk.BrowseToDmtk(tknoa,ttknoa,tkcoa,tknoa.Location.X,tknoa.Location.Y+tknoa.Height,tknoa.Width+ttknoa.Width+2,tknoa.Height,100);
			}
		}

		private void tknoa_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) liststk.Focus();
			else if (e.KeyCode==Keys.Enter)
			{
				if (liststk.Visible)	liststk.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void tknoa_Validated(object sender, System.EventArgs e)
		{
			DataRow r=a.getrowbyid(dttk,"stk='"+tknoa.Text+"'");
			ttknoa.Text=(r!=null)?r["ttk"].ToString():"";
			load_mtm(tknoa.Text,kmno);
		}

		private void tkcoa_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==tkcoa)
			{
				Filter_stk(tkcoa.Text,liststk);
				liststk.BrowseToDmtk(tkcoa,ttkcoa,butTim,tkcoa.Location.X,tkcoa.Location.Y+tkcoa.Height,tkcoa.Width+ttkcoa.Width+2,tkcoa.Height,100);
			}
		}

		private void tkcoa_Validated(object sender, System.EventArgs e)
		{
			DataRow r=a.getrowbyid(dttk,"stk='"+tkcoa.Text+"'");
			ttkcoa.Text=(r!=null)?r["ttk"].ToString():"";
			load_mtm(tkcoa.Text,kmco);
		}

		private void dataGrid2_CurrentCellChanged(object sender, System.EventArgs e)
		{
			try
			{
				l_id=long.Parse(dataGrid2[dataGrid2.CurrentCell.RowNumber,0].ToString());				
			}
			catch{l_id=0;}
			load_head();
		}

		private void frmTimct_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (bClear)
			{
				lk.SelectedIndex=chucnang.SelectedIndex=lctug.SelectedIndex=nhom.SelectedIndex=hoatdong.SelectedIndex=chuong.SelectedIndex=nghiepvu.SelectedIndex=tcnkp.SelectedIndex=-1;
				bClear=false;
			}
		}

		private void chucnang_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==chucnang) load_loai();
		}

		private void load_mtm(string stk,ComboBox cb)
		{
			DataTable tmp;
			DataRow r=a.getrowbyid(dttk,"stk='"+stk+"'");
			if (r!=null)
			{
				sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm"].ToString())+" and sudung=1 order by stt";
				tmp=a.get_data(sql).Tables[0];
				cb.DataSource=tmp;
				if (cb.Name=="kmno")
				{
					sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm2"].ToString())+" and sudung=1 order by stt";
					kmno2.DataSource=a.get_data(sql).Tables[0];
					sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm3"].ToString())+" and sudung=1 order by stt";
					kmno3.DataSource=a.get_data(sql).Tables[0];
					sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm4"].ToString())+" and sudung=1 order by stt";
					kmno4.DataSource=a.get_data(sql).Tables[0];
				}
				else if (cb.Name=="kmco")
				{
					sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm2"].ToString())+" and sudung=1 order by stt";
					kmco2.DataSource=a.get_data(sql).Tables[0];
					sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm3"].ToString())+" and sudung=1 order by stt";
					kmco3.DataSource=a.get_data(sql).Tables[0];
					sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm4"].ToString())+" and sudung=1 order by stt";
					kmco4.DataSource=a.get_data(sql).Tables[0];
				}
				cb.Enabled=tmp.Rows.Count>0;
				if (cb.Name=="kmno")
				{
					kmno2.Enabled=kmno2.Items.Count>0;
					kmno3.Enabled=kmno2.Items.Count>0;
					kmno4.Enabled=kmno4.Items.Count>0;
				}
				else if (cb.Name=="kmco")
				{
					kmco2.Enabled=kmco2.Items.Count>0;
					kmco3.Enabled=kmco2.Items.Count>0;
					kmco4.Enabled=kmco4.Items.Count>0;
				}
			}			
		}

		private void tt_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==tt) st2.Enabled=tt.SelectedIndex==3;
		}

		private void butSua_Click(object sender, System.EventArgs e)
		{
			try
			{
				l_id=long.Parse(dataGrid2[dataGrid2.CurrentCell.RowNumber,0].ToString());
				s_ngay=dataGrid2[dataGrid2.CurrentCell.RowNumber,6].ToString();
				int lctug=int.Parse(dataGrid2[dataGrid2.CurrentCell.RowNumber,1].ToString());
				string _mmyy=dataGrid2[dataGrid2.CurrentCell.RowNumber,2].ToString()+s_mmyy.Substring(2);
				DataRow r=a.getrowbyid(dtloai1,"id="+lctug);
				if (r!=null)
				{
					int loai=int.Parse(r["chucnang"].ToString());
					int dutoan=(loai==1)?a.lctug_dutoanns_tm:(loai==2)?a.lctug_dutoanns_nghang:(loai==5)?a.lctug_dutoanns_vattu:a.lctug_dutoanns;
					string ten=(loai==1)?"Kế toán tiền mặt":(loai==2)?"Kế toán ngân hàng - kho bạc":(loai==5)?"Kế toán vật tư hàng hóa":"Kế toán các nghiệp vụ khác";
					if (loai!=2)
					{
						frmNhapct f1=new frmNhapct(a,_mmyy,s_ngay,s_chuong,s_lk,s_lctug,s_nghiepvu,loai,i_userid,ten,bAdmin,dutoan,l_id);
						f1.ShowDialog(this);
					}
					else
					{
						frmNhapng f2=new frmNhapng(a,_mmyy,s_ngay,s_chuong,s_lk,s_lctug,s_nghiepvu,loai,i_userid,ten,bAdmin,dutoan,l_id);
						f2.ShowDialog(this);
					}
				}
			}
			catch{}
		}

        private void label17_Click(object sender, EventArgs e)
        {

        }
	}
}
